package com.ddpt.permission.dubbo.tokenVerify;

import com.lh.center.common.constant.RedisPrefix;
import com.lh.center.common.enums.MarketingApp;
import com.lh.center.permission.api.dubbo.TokenVerifyService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

@DubboService(group = "storeLogin",interfaceName = "com.lh.center.permission.api.dubbo.TokenVerifyService")
public class StoreTokenVerifyServiceImpl implements TokenVerifyService {

    @Value("${admin.timeout.store:30}")
    private Integer loginTimeout;

    @Resource
    private StringRedisTemplate stringRedisTemplate;

    @Override
    public void refresh(String token) {
        stringRedisTemplate.expire(RedisPrefix.STORE_ADMIN_USER_TOKEN + token,loginTimeout, TimeUnit.MINUTES);
    }

    @Override
    public String getInfo(String token) {
        refresh(token);
        return stringRedisTemplate.opsForValue().get(wholeToken(MarketingApp.store,token));
    }
}
